<?php
class ent_sitemap extends Lead_EDO_Object_Abstract
{
    
    static $_tables = array('ent_sitemap');
    
    
    
    static public function displayBranch($langid, $navi, $level = 1)
    {
        $app = Led_Application::getInstance();
        
        static $langs = array();
                        
        if(!isset($langs[$langid]))
            $langs[$langid] = $app->getEdo()->fetch($langid, 'ent_language');
            
            
                       
        $thelang = $langs[$langid];
        
        $app->getEdo()->requireType('ent_navigationmenu');
        $temp2 = ent_navigationmenu::getBranch($langid, $navi);
                
        if ($temp2->count()) {
            $classes[] = "level_generic";
            $classes[] = "level_$level";
            if ($level > 1) {
                $classes[] = "sublevel";
            }
        
            $classes = implode(" ", $classes);
        
            print "\n<ul class=\"" . $classes . "\">\n";
            foreach ($temp2 as $key => $value) {
                                        
                $tempus = ent_navigationmenu::getBranch($langid, $value->id);				

                print "<li>";
                if (!$tempus->count() OR $thelang->navisystem == 0) {
                    print"<a href=\"" . $value->linkurl . "\">";
                }
                print $value->title;
                if (!$tempus->count() OR $thelang->navisystem == 0) {
                    print "</a>";
                }
                print "</li>\n";
        
                if ($tempus->count()) {
                    self::displayBranch($langid, $value->id, $level+1);
                }
        
            }
            print "</ul>\n";
        }
    }

    
}
